/**
 * 
 */
package util;

import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

/**
 * @author Xiaohui
 * 
 */
public class TextUtil {

	// convert [1, 2, 3, 4] to 1 2 3 4
	public static String flatenSet(Set aset) {
		String val = aset.toString();
		// remove first and last ele
		val = val.substring(1, val.length() - 1);
		StringTokenizer st = new StringTokenizer(val, ",");
		String result = "";
		while (st.hasMoreElements()) {
			result += st.nextToken();
		}

		return result;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		HashSet<Integer> container = new HashSet<Integer>();
		container.add(2);
		container.add(3);
		container.add(4);
		System.out.println(flatenSet(container));
	}

}
